/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package chameleon.view.command;

import chameleon.model.NuGatManager.NuGatManager;
import chameleon.view.input.Input;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * This command check if the last strategy encoded (possibly modified strategy
 * is a always a winning strategy.
 * 
 * @author simon
 */
class CheckStrategyIsWinning extends Command {

    public CheckStrategyIsWinning(Input input, boolean help) {
        super(input, false, help);
    }

    @Override
    public Input execute() {
        
        if (help_){
            outputManager_.displayString("This command check if the last strategy encoded (possibly modified strategy"
                +" is a always a winning strategy.\n"
                    + "check_strategy_is_winning [ | -h]");
        }
        else{
            InternalCheckCommand check = new InternalCheckCommand(input_, 3);
            if (check.isOk()){
                try {
                    NuGatManager manager = (NuGatManager) input_.getManager();
                    manager.checkIfStrategyIsWinning();
                } catch (IOException ex) {
                    Logger.getLogger(CheckStrategyIsWinning.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
        
        return input_;
    }
    
}
